import normalForm from '@/components/normalForm/form'
import normalChartDialog from '@/components/chartDialog/index'
import {specialTypeCheck} from '@/utils'

export default {
  data() {
    return {
      addOrUpdateVisible: false
    }
  },
  methods: {
    openChartDialog(option) {
      const charDialog = this.$refs.charDialog

      if (!this.R.isNil(charDialog)) {
        charDialog.openChartDialog(option)
      }
    },
    getDataList() {
      const tableView = this.$refs.view

      if (this.R.isNil(tableView)) {
        return
      }
      return tableView.getDataList()
    },
    getParams() {
      const data = this.R.propOr({}, 'dataForm', this.chartSearchObj)
      const params = {}

      Object.keys(data).forEach((key) => {
        if (!this.R.isNil(data[key]) && !this.R.equals('', data[key])) {
          params[key] = data[key]
        }
      })
      return specialTypeCheck(params)
    },
    commitChartSearch(option) {
      this.$refs.chart.init(Object.assign(this.getParams(), option))
    }
  },
  components: {
    normalForm,
    normalChartDialog
  }
}
